package com.adee.nowcoder.huawei;

import java.util.*;

public class T027_HJ027 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String str = in.nextLine();
            String[] arr = str.trim().split(" ");
            int n = Integer.parseInt(arr[0]);
            String [] dic = Arrays.copyOfRange(arr, 1, n+1);
            String x = arr[arr.length-2];
            int k = Integer.parseInt(arr[arr.length-1]);
            List<String> brothers = new ArrayList<>(n);
            for (int i = 0; i < dic.length; i++) {
                if(isBrother(dic[i],x)) brothers.add(dic[i]);
            }
            brothers.sort(new Comparator<String>() {
                @Override
                public int compare(String s1, String s2) {
                    return s1.compareTo(s2);
                }
            });
            System.out.println(brothers.size());
            System.out.println(brothers.get(k-1));

        }
    }

    private static boolean isBrother(String s, String x) {
        if(s != null && x != null && s.length() == x.length() && !s.equals(x)) {
            char[] r1 = s.toCharArray();
            Arrays.sort(r1);
            char[] r2 = x.toCharArray();
            Arrays.sort(r2);
            return new String(r1).equals(new String(r2));
        }
        return false;
    }
}
